home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir42 / dbinde.zip / DBINDENT.DOC < prev    next >
Text File  |  1993-10-10  |  4KB  |  76 lines

  1. Looking for a way to make your program listings easier to read?  Did you ever
  2. think you were going crazy trying to find mismatched IF...ENDIFs and DO...
  3. WHILE-ENDOs?  DBINDENT.PRG is a dBase III+ program that evolved to make such
  4. tasks much easier.
  5.  
  6. You'll need a .DBF file named DBINDENT consisting of 1 character type field
  7. named ENT.  My DBINDENT.DBF has a field width of 120 so the ends of deeply
  8. indented lines won't get lost but you can make it any size you like up to 254.
  9. Sure, going over 80 may result in lines extending past the edge of the screen
  10. but I use an editor that lets me get to that data, too.  (Try QEdit v2.15 by
  11. SemWare; for the power it has it's a fantastic buy.  I use it in place of
  12. 'real' word processors so much I've forgotten most of WordPerfect's commands.)
  13.  
  14. The program is pretty straightforward in the way it's used.  I always clear
  15. anything left over in DBINDENT.DBF and set it up as follows:
  16.        USE DBINDENT
  17.        ZAP
  18.        CLEAR ALL
  19.        APPEND FROM <file spec> SDF
  20. <file spec> must include the path, file name, and file name extension of the
  21. program you want to process unless it's in the dBase default directory.  The
  22. SDF designation is necessary to read the file as full lines of data.
  23.  
  24. At this point you simply enter the command DO DBINDENT at the dBase prompt.
  25.  
  26. DBINDENT.PRG first trims empty space from the left end of each line, then
  27. looks for the following commands to indent or de-indent as appropriate:
  28. (DBINDENT looks for these commands in both their long or short forms.)
  29.         DO WHILE         ENDDO
  30.         IF               ENDIF       ELSE
  31.         DO CASE          ENDCASE     OTHERWISE
  32.         PROCEDURE        RETURN      PARAMETERS
  33.  
  34. It 'temporarily de-indents' ELSE, OTHERWISE and PARAMETERS statements so
  35. they're even with IF, DO CASE AND PRODCURE lines for easier reading and all
  36. are capitalized unless a TEXT command is found; TEXT...ENDTEXT lines are not
  37. affected at all.  And in the case of @ SAY...GET lines, upper/lower case is
  38. not affected plus you have the option of setting the line even with the left
  39. margin.  Comment lines can be indented, left flush at the left end of the line
  40. or deleted according to your preference with minor changes.  It's also easy
  41. to disable the capitalizing of lines other than @ SAY...GETs and TEXT.
  42.  
  43. When you're all done, the command
  44.        COPY TO <file spec> DELI WITH BLANKS
  45.                             will give you an ASCII type listing.  It's not
  46. necessary for the <file spec> in the COPY TO command be the same as in the
  47. APPEND FROM command.  As a matter of fact, it might be wise to use a similar
  48. but different name until you test the indented program.
  49.  
  50. I use DBINDENT quite often with good results and, while it takes a little time
  51. to process listing with a large number of lines, it been worth the time as a
  52. debugging tool.  Besides, it leaves you with a listing you're not ashamed to
  53. show to your boss without spending hours indenting with an editor, too.  Let
  54. him (or her as the case may be) think you spent all night slaving in front of
  55. your monitor instead of lounging in front of the TV anyway; maybe you'll get
  56. that raise you deserve.
  57.  
  58. (Another hint:  If you use && to add comments to the ends of command lines and
  59. tried to remove them you've probably found that && in a command, even if you
  60. enclose it in quotes, truncates everything to the right in the command itself
  61. so it doesn't work.  You can remove these comments and leave the rest of the
  62. line intact with the following command while using DBINDENT:
  63.     REPLACE LINE WITH LEFT(LINE, AT(("&"+"&"), ENT) -1) FOR ("&"+"&") $ LINE
  64.  
  65. A companion program with also uses DBINDENT.DBF is CHKLOOPS.PRG.  This program
  66. deletes everything in the file, then recalls selected commands, (IF, ENDIF, DO
  67. WHILE, ENDDO, etc) and provides a count for each.  If the counts don't match,
  68. you can copy the results to a separate file so search out the mismatched
  69. command.  (I'm forever ending DO WHILEs with ENDIFs.)  There are two reasons
  70. CHKLOOPS should be used AFTER running DBINDENT.  First, running DBINDENT
  71. before CHKLOOPS makes it easier to find errors and secondly, CHKLOOPS does NOT
  72. recall all the original statements when it's done running.
  73.  
  74. So there you are.  Good luck and good hunting.  I hope you find that DBINDENT
  75. and/or CHKLOOPS are as useful to you as they have been for me.
  76.